# !/usr/local/bin/ruby -w 
# parse.rb
#
# This Program removes the > and : symbol from the partially parsed file and generates the file which
# can be directly dumped into the databse
# 
# Authors:: Bhushan Kotnis, Akshay Jog (mailto: {bkotnis,akshayj}@eden.rutgers.edu )
# License:: Distributes under the same terms as Ruby

system("filterclass.rb")
#system call to partially parse the raw tcpdump file

file=File.open("filtered.txt","r")
#filtered file is a intermediate file which has partially parsed data
p=File.open("perfect_parse.txt","w")
#perfect_parse is the file which has the data which can be directly stored into the DB

while line=file.gets
line.strip!
# strip removes \n from the string
str1=file.gets
str1.strip!
str2=file.gets
str2.strip!
str3=file.gets
str3=str3.gsub(/>/,"")
#gsub substitues the pattern > with the ""
str3=str3.strip!
str3=str3.gsub(/:/,"")
#=gsub substitues the pattern : with the ""
str4=file.gets
str5=line+" "+str1+" "+str2+" "+str3
#concatenetating strings to store into the perfect_parse file
p.puts str5

end
file.close
p.close